package com.yxhl.zoume.domain.interactor.car.expresscar;

import com.google.protobuf.GeneratedMessageV3;
import com.yxhl.protobuf.MpvModelRequest;
import com.yxhl.protobuf.MpvModelResponse;
import com.yxhl.zoume.data.http.repository.car.ExpressCarRepository;
import com.yxhl.zoume.domain.DomainConstants;
import com.yxhl.zoume.domain.interactor.base.ProtoUseCase;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Author：zhongshan   
 * Date：2016/12/14 15:53      
 * Description：查车型价格
 */
public class QueryVehicleModelUseCase extends ProtoUseCase<MpvModelResponse> {

    private ExpressCarRepository repository;

    @Inject
    public QueryVehicleModelUseCase(@Named(DomainConstants.UI_THREAD) Scheduler uiThread,
                                    @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
                                    ExpressCarRepository repository) {
        super(uiThread, executorThread);
        this.repository = repository;
    }

    @Override
    protected Observable<MpvModelResponse> buildObservable(GeneratedMessageV3 message) {
        return repository.queryVehicleModel((MpvModelRequest) message)
                .subscribeOn(executorThread)
                .observeOn(uiThread);
    }
}
